import os
import threadpool

'''
用you-get多线程批量下载视频片段ts，然后合成mp4,尤其适合会员可回放视频哦……
'''

urlList = ["https://tv.cctv.com/2015/08/27/VIDE1440638136134698.shtml?spm=C55853485115.PYUgfrkuJQyH.0.0",
           "https://tv.cctv.com/2015/08/27/VIDE1440638297499214.shtml?spm=C55853485115.PYUgfrkuJQyH.0.0",
           "https://tv.cctv.com/2015/08/27/VIDE1440680260942615.shtml?spm=C55853485115.PYUgfrkuJQyH.0.0",
           "https://tv.cctv.com/2021/07/27/VIDE0tSSY5rGvu4jl2deH8g5210727.shtml?spm=C55853485115.PYUgfrkuJQyH.0.0",
           "https://tv.cctv.com/2021/04/20/VIDEA6KKtHOJPjscCdLOhxQD210420.shtml?spm=C55853485115.PhO6T4rt8QwC.0.0",
           "https://tv.cctv.com/2015/08/27/VIDE1440690318838511.shtml?spm=C55853485115.PhO6T4rt8QwC.0.0",
           "https://tv.cctv.com/2015/08/28/VIDE1440770234059868.shtml?spm=C55853485115.PYUgfrkuJQyH.0.0",
           "https://tv.cctv.com/2019/08/22/VIDEPHOJEe3uBX7NXdauBV5n190822.shtml?spm=C55853485115.PYUgfrkuJQyH.0.0",
           "https://tv.cctv.com/2015/08/28/VIDE1440772930946988.shtml?spm=C55853485115.PYUgfrkuJQyH.0.0",
           "https://tv.cctv.com/2015/08/29/VIDE1440852851434489.shtml?spm=C55853485115.PYUgfrkuJQyH.0.0",
           "https://tv.cctv.com/2015/08/29/VIDE1440856088410501.shtml?spm=C55853485115.PYUgfrkuJQyH.0.0",
           "https://tv.cctv.com/2015/08/29/VIDE1440859330983654.shtml?spm=C55853485115.PYUgfrkuJQyH.0.0",
           "https://tv.cctv.com/2015/08/30/VIDE1440938896317730.shtml?spm=C55853485115.PYUgfrkuJQyH.0.0",
           "https://tv.cctv.com/2015/08/30/VIDE1440946261187986.shtml?spm=C55853485115.PYUgfrkuJQyH.0.0",
           "https://tv.cctv.com/2015/08/30/VIDE1440946622069379.shtml?spm=C55853485115.PYUgfrkuJQyH.0.0",
           "https://tv.cctv.com/2015/08/31/VIDE1441026199551701.shtml?spm=C55853485115.PYUgfrkuJQyH.0.0",
           "https://tv.cctv.com/2015/08/31/VIDE1441028703758127.shtml?spm=C55853485115.PYUgfrkuJQyH.0.0",
           "https://tv.cctv.com/2015/08/31/VIDE1441031977661877.shtml?spm=C55853485115.PYUgfrkuJQyH.0.0",
           "https://tv.cctv.com/2021/01/02/VIDEOHsip0oMyTXciRIQBobv210102.shtml?spm=C55853485115.PYUgfrkuJQyH.0.0",
           "https://tv.cctv.com/2015/09/01/VIDE1441114924229429.shtml?spm=C55853485115.PhO6T4rt8QwC.0.0",
           "https://tv.cctv.com/2015/09/01/VIDE1441114580144553.shtml?spm=C55853485115.PYUgfrkuJQyH.0.0",
           "https://tv.cctv.com/2015/09/02/VIDE1441123217050936.shtml?spm=C55853485115.PYUgfrkuJQyH.0.0",
           "https://tv.cctv.com/2015/09/02/VIDE1441123216926923.shtml?spm=C55853485115.PYUgfrkuJQyH.0.0",
           "https://tv.cctv.com/2015/09/02/VIDE1441198279590961.shtml?spm=C55853485115.PYUgfrkuJQyH.0.0",
           "https://tv.cctv.com/2015/09/02/VIDE1441200794638964.shtml?spm=C55853485115.PYUgfrkuJQyH.0.0",
           "https://tv.cctv.com/2015/09/02/VIDE1441205104539993.shtml?spm=C55853485115.PYUgfrkuJQyH.0.0",
           ]

def download(i):
    try:
        print('正在多线程下载： ')
        os.system("you-get -o D:\资料\亮剑 " + i)
        print('视频下载完成，保存至："D:\资料\亮剑"', i)
    except Exception as e:
        print('error ' + e)

pool = threadpool.ThreadPool(3)
requests = threadpool.makeRequests(download, urlList)
[pool.putRequest(req) for req in requests]
pool.wait()
print('下载结束')




# https://om.tc.qq.com/video.dispatch.tc.qq.com/f00356izktn.mp4?vkey=FB625824A1BB4B63B697EBBDC1730EAFE47B2D8024A6277B8BD06AA678BE0D7600A67A71E046D3C3AD54D3F3131FB17CBA32C518E8A1A06C5E0901095C088BC8A35577687916615EE684393FF6B96C9E25DBB9780D3CE0C43A3F08A55637A79D80FF0C70EDE2D008E3895AA19CE643F38018F9C92943B07BEC4DD8D30AC321222AEB958979E045132403634136146577&sdtfrom=v1010&type=mp4&platform=10901&br=117&fmt=10218&sp=0&guid=36517100a210166dc58bd32c915cab106a2
# https://om.tc.qq.com/video.dispatch.tc.qq.com/r00356hf2a5.mp4?vkey=671992A547A64EE70AB3543A4AC1832A843DFAE75D43366ACBA86FE38A5A3005A393D3B7ECE5C8F2C95E79038FE4EB81C9CD195A18AEA89B5ABB986E08DD2D92B3489FEF2FCAF5078E6BA7CA76D605B329C7404FA1073DAE2DCE6598AEE96DC6FEF26EC7C17017AF316EAB1D091FE6BA8F8E7C80B37ED6A1011021643E46A8F0F59284525C3AE5C83361CC7778E602A2&sdtfrom=v1010&type=mp4&platform=10901&br=117&fmt=10218&sp=0&guid=3fd7339423c510af4cbc4b4f5cc610906d


